package com.ruoyi.project.fire.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.fire.domain.FireInspectionProject;
import com.ruoyi.project.fire.service.IFireInspectionProjectService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 存储排查项目名称Controller
 * 
 * @author 布衣
 * @date 2025-05-13
 */
@RestController
@RequestMapping("/system/project")
public class FireInspectionProjectController extends BaseController
{
    @Autowired
    private IFireInspectionProjectService fireInspectionProjectService;

    /**
     * 查询存储排查项目名称列表
     */
    @PreAuthorize("@ss.hasPermi('system:project:list')")
    @GetMapping("/list")
    public TableDataInfo list(FireInspectionProject fireInspectionProject)
    {
        startPage();
        List<FireInspectionProject> list = fireInspectionProjectService.selectFireInspectionProjectList(fireInspectionProject);
        return getDataTable(list);
    }

    /**
     * 导出存储排查项目名称列表
     */
    @PreAuthorize("@ss.hasPermi('system:project:export')")
    @Log(title = "存储排查项目名称", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FireInspectionProject fireInspectionProject)
    {
        List<FireInspectionProject> list = fireInspectionProjectService.selectFireInspectionProjectList(fireInspectionProject);
        ExcelUtil<FireInspectionProject> util = new ExcelUtil<FireInspectionProject>(FireInspectionProject.class);
        util.exportExcel(response, list, "存储排查项目名称数据");
    }

    /**
     * 获取存储排查项目名称详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:project:query')")
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") Long projectId)
    {
        return success(fireInspectionProjectService.selectFireInspectionProjectByProjectId(projectId));
    }

    /**
     * 新增存储排查项目名称
     */
    @PreAuthorize("@ss.hasPermi('system:project:add')")
    @Log(title = "存储排查项目名称", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FireInspectionProject fireInspectionProject)
    {
        return toAjax(fireInspectionProjectService.insertFireInspectionProject(fireInspectionProject));
    }

    /**
     * 修改存储排查项目名称
     */
    @PreAuthorize("@ss.hasPermi('system:project:edit')")
    @Log(title = "存储排查项目名称", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FireInspectionProject fireInspectionProject)
    {
        return toAjax(fireInspectionProjectService.updateFireInspectionProject(fireInspectionProject));
    }

    /**
     * 删除存储排查项目名称
     */
    @PreAuthorize("@ss.hasPermi('system:project:remove')")
    @Log(title = "存储排查项目名称", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable Long[] projectIds)
    {
        return toAjax(fireInspectionProjectService.deleteFireInspectionProjectByProjectIds(projectIds));
    }
}
